﻿using Microsoft.AspNetCore.Mvc;
using System.Net.WebSockets;

namespace xk.mqm.test.userservice.Controllers
{
    /// <summary>
    /// websocket
    /// </summary>
    [Route("[controller]/[action]")]
    [ApiController]
    public class WebSocketController : ControllerBase
    {/// <summary>
     /// 
     /// </summary>
        private Dictionary<string, WebSocket> _userConnections;
        public WebSocketController()
        {
            _userConnections = new Dictionary<string, WebSocket>();
            _userConnections = WebSocketMiddleware._userConnections;
            // 假设你有代码来维护_userConnections字典
        }
        /// <summary>
        /// 获取WebSocket的连接人数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int GetSumUser()
        {
            return _userConnections.Count;
        }

    }
}
